package org.yray.file;

import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

public class ReadWav {
    public static void main(String[] args) {

        try {
            RandomAccessFile randomAccessFile = new RandomAccessFile("", "r");
            FileChannel fileChannel = randomAccessFile.getChannel();
            ByteBuffer buff = ByteBuffer.allocate(1024);

            while (true) {
                // 4. 从通道读取数据 & 写入到缓冲区
                int r = fileChannel.read(buff);
                // 返回-1代表已读取到该通道数据的末尾，循环可以结束
                if (r == -1) {
                    break;
                }
                // 5. 传出数据准备：调用flip()方法
                buff.flip();


                // 7. 复位缓冲区
                buff.clear();
            }

        }catch (Exception e)
        {

        }
    }
}
